package workexp.alg.dp;

import org.junit.Test;

public class MaxProfit {
    public int maxProfit(int[] prices) {
        int len = prices.length;
        if(len<2){
            return 0;
        }
        int cur=0,max=0;
        for(int i =1;i<len;i++){
            cur = Math.max(cur,0)+prices[i]-prices[i-1];
            max = Math.max(cur,max);
        }
        return max;
    }

    @Test
    public void test(){
        int[] nums = {3,2,6,5,0,3};
        int s = maxProfit(nums);
        System.out.println(s);
    }

}
